import clickhouse_connect
import random
from datetime import datetime

connect_info = {
    'port': 8123,
    'host': '192.168.103.43',
    'username': 'admin',
    'password': '@Abcd1234',
    'database': 'saas'
}
client = clickhouse_connect.get_client(**connect_info)
column_list = ['log_id', 'log_time', 'tags', 'content', 'type']
insert_data = []
num = 0
table_name = 'dataset_invalid_original_log_local'
while num < 40:
    log_id = str(random.randint(10 ** 14, 10 ** 16))
    str_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
    log_time = datetime.strptime(str_time, '%Y-%m-%d %H:%M:%S')
    tags = '1'
    content = '''
    Key: {
	"data": {
		"authorization_condition": null,
		"license_result": "0",
		"co_op_name_type": "00",
		"apply_message": "select * from std_gold_apply_approve_log order by log_time desc",
		"cooperate_type": "test",
		"work_order_type": null,
		"treasury_apply_id": "",
		"apply_org_name_path": null,
		"co_op_name": "jixiaoxiang",
		"across_two_level_org": null,
		"apply_org_code": "181",
		"co_op_org_name": null,
		"authorization_info": "",
		"scene_name": null,
		"control_type": "CT_FREE_TIME_TRIGER",
		"belong_resource": "JTNGZHZC",
		"co_op_org_name_path": null,
		"log_id": "9701757733873384303",
		"end_time": "2025-04-13 22:12:36",
		"scene_id": "",
		"target_type": "TT_BUSINESS_APP",
		"resource_type": "应用系统",
		"trigger_mode": null,
		"license_model": null,
		"begin_time": "2025-04-13 20:00:36",
		"apply_time": "2025-04-12 09:42:36",
		"apply_name": "tszh_qingzhouzhiban2",
		"log_time": "2025-05-15 14:12:53",
		"data_source": null,
		"work_order_num": null,
		"time_duration_desc": "0时30分0秒",
		"apply_org_name": null,
		"co_op_org_code": "181",
		"time_duration_minutes": "0",
		"op_type_code": null,
		"slave_account": "weihu",
		"approve_time": "2025-04-13 11:00:36",
		"collect_time": "2025-05-15 02:12:53",
		"resource_name": "一级排队系统"
	},
	"datasetCode": "std_gold_apply_approve_log",
	"datasetSn": 300324100680002,
	"realTimeAnalysis": True
}
    '''
    str_type = '1'
    insert_data.append(
        [log_id, log_time, tags, content, str_type])
    num += 1
client.insert(table_name, data=insert_data, column_names=column_list)
client.close()
